Level Correction Function and pDIF
Category:Guides Cap Attack/Defense Ratio The ratio of an attacker's Attack versus the defender's Defense, Ratio, is capped for the purposes of damage calculation: *Ratio is capped at 2.25 for one-handed melee weapons. *Ratio is capped at 2.25 for two-handed melee weapons. Level correction is then applied to find cRatio, upon which the multipliers to find pDIF work. This entails that Level Correction will always have an effect on damage output. *As an extreme example, an attacker with 600 attack against a target with 200 defense has a melee attack/defense Ratio of 3.0. This Ratio will be capped to 2.2 with a two-handed weapon, meaning only 440 attack is actually required to maximize Melee pDIF output against this target, regardless of its level. The Level Correction function The Level Correction function modifies your (ranged) attack / monster defense ratio before it is used in the calculation of pDIF. *''If the target is a higher level than the attacking player, then a level corrected ratio is needed before calculating pDIF. *''This is not, however, applied in reverse if the player is the higher level being attacked.'' *''When fighting EM monsters or lower, level correction is always zero, meaning no 'bonus' is applied for attacking lower level targets.'' After Ratio is capped at 2.25, or for any lower value: *''Melee cRatio = Ratio - 0.050 x level difference'' Using the capped 2.25 Ratio from before, for a level 75 against a level 80 target, melee cRatio is then: *''(2.2 - 0.05*5) = 1.95''. Level correction is also applied to Ranged Attacks, but no Ratio cap has been determined: *''Ranged cRatio = Ratio - 0.025 x level difference'' Once the level-corrected ratio is calculated the game generates random numbers between two values 'a' and 'b'. This random number is then multiplied by another random number (uniform between 1 and 1.05). Therefore, the minimum observed value is 'a' and the maximum value observed is 'b*1.05'. Due to flooring, it take a lot of hits to reach those extreme values. *One Handers, Two Handers and Ranged pDIF scaling multipliers have the same formulas (only verified for 1 handed weapons so far and up to 2.0 ratio). Pdif maximum and minimum 1-Handers Pdif Let r=cRatio, as computed as above. :Maximum b has the following formulas: : :and Minimum a has the following formulas: : A simple way to express the function 'a' and 'b' is to use the positive and negative parts of numbers : p(x)=max(x,0) and n(x)=max(-x,0). Then * a®=1+(10/9)x(p(max(r,0.5)-1.5)-n(max(r,0.5)-1.25)) * b®=1+(10/9)x(p(r-0.75)-n(r-0.5)) 2-Handers Pdif Note those formulas are likely outdated ; use the 1 handed formulas instead. :Max pDIF has the following formulas: : *For both one- and two-handed melee weapons, a Critical Hit adds 1.0 to intermediate pDIFa value and capped at 3.0 before the x1.00-1.05 randomization is applied. :and Min pDIF has the following formulas: : *For both one- and two-handed melee weapons, a Critical Hit adds 1.0 to intermediate pDIFa value and capped at 3.0 before the x1.00-1.05 randomization is applied. Ranged Attack Pdif : : *When cRatio exceeds 3.0, cRatio is 3.0 (capped for ranged) *Rules for ranged Critical Hit :Ranged critical hit always multiplies your pDIF by 1.25, and is not capped. :Example: When your pDIF is 3.0 and you score a critical hit, your pDIF will be 3.75 Distribution of melee hits For a one handed weapon, with a damage 'DMG' (which includes fstr), and a cratio 'r', the above formula give a minimum pdif called 'a' and a maximum pdif called 'b' (which is the maximum before the randomizer is applied so b*1.05 is the real maximum). Note that the value of b and a used here are almost those above except a has no lower cap : * a®=1+(10/9)x(p(r-1.5)-n(r-1.25)) * b®=1+(10/9)x(p(r-0.75)-n(r-0.5)) * For 0 <= r <= 2.0 the distribution of random damage observed in-game follows the following law : : where rand(x;y) is an uniform randomizer generating values within the range x,y, and U is a bernouilli variable of parameter 'q' described below (q=P(U=1)). The variables U and the 2 randomizers are independantly generated. : The distribution has a spike appearing in the middle of the distribution in the range DMG,DMG*1.05. The spike goes to the upper side if r descreases and goes to the lower side if r increases. Around 28% of the hits values lie in the intervale DMG,DMG*1.05, and this doesn't vary with r. : When r exceeds 1.25, a remains equal to a=DMG until r=1.5, and the distribution presents a spike on its lower bound. The spike frequency decreases to zero when r reaches r=1.5. : When r falls below 0.75, b remains equal to b=DMG until r=0.5, and the distribution presents a spike on its upper bound. The spike frequency decreases to zero when r reaches r=0.5. : DMG doesn't belong to the hits distribution range in this case. The distribution is uniform on the interval a*1.05*DMG,b*DMG and logaritmic near the edges (0 on the edges). : DMG doesn't belong to the hits distribution range in this case. The distribution is uniform on the interval a*1.05*DMG,b*DMG and logaritmic near the edges (0 on the edges). * for 0.5<=r<=1.5 the frequency spike equals q+(1-q)*DMG*ln(1.05)/(b-a) * Though testing has to be done, crit distribution is expected to follow a similar rule, except the uniform variable is generated between a+1 and b+1, then capped at 3, and then only multiplied by the 5% randomizer. Therefore a spike cannot happen : critdamage:=(1+min(U,2))*eta with U uniform on a,b and eta uniform on 1,1.05 Average pdif expression Using the above model, we deduce the expression of the average pdif for 1-handed weapons (as well as 2 handed weapons until verifications) : Using the above model, we deduce the expression of the average crit pdif for 1-handed weapons (as well as 2 handed weapons until verifications) If r<1.65 (ie b<2) then mc=1.025*(1+(a+b)/2) else mc=1.025*(1+(4b-a^2-4)/(2(b-a)) or : See also *Base Damage *Calculating Weapon Skill Damage *Calculating Blood Pact Damage *Calculating Blue Magic Damage